package com.ynu.appuser.controller;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ynu.appuser.domain.appuser.MdUser;
import com.ynu.appuser.service.IMdUserService;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ynu.appuser.domain.appuser.MdUserScore;
import com.ynu.appuser.service.IMdUserScoreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 医生给app用户打的评分Controller
 *
 * @author ruoyi
 * @date 2022-12-09
 */
@RestController
@RequestMapping("/appuser/score")
public class MdUserScoreController extends BaseController {
    @Autowired
    private IMdUserScoreService mdUserScoreService;

    /**
     * 查询医生给app用户打的评分列表
     */
    @PreAuthorize("@ss.hasPermi('appuser:score:list')")
    @GetMapping("/list")
    public TableDataInfo list(MdUserScore mdUserScore) {
        startPage();
        List<MdUserScore> list = mdUserScoreService.selectMdUserScoreList(mdUserScore);
        return getDataTable(list);
    }

    /**
     * 导出医生给app用户打的评分列表
     */
    @PreAuthorize("@ss.hasPermi('appuser:score:export')")
    @Log(title = "医生给app用户打的评分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MdUserScore mdUserScore) {
        List<MdUserScore> list = mdUserScoreService.selectMdUserScoreList(mdUserScore);
        ExcelUtil<MdUserScore> util = new ExcelUtil<MdUserScore>(MdUserScore.class);
        util.exportExcel(response, list, "医生给app用户打的评分数据");
    }

    /**
     * 获取医生给app用户打的评分详细信息
     */
    @PreAuthorize("@ss.hasPermi('appuser:score:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(mdUserScoreService.selectMdUserScoreById(id));
    }

    /**
     * 新增医生给app用户打的评分
     */
    @PreAuthorize("@ss.hasPermi('appuser:score:add')")
    @Log(title = "医生给app用户打的评分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MdUserScore mdUserScore) {
        return toAjax(mdUserScoreService.insertMdUserScore(mdUserScore));
    }

    /**
     * 修改医生给app用户打的评分
     */
    @PreAuthorize("@ss.hasPermi('appuser:score:edit')")
    @Log(title = "医生给app用户打的评分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MdUserScore mdUserScore) {
        return toAjax(mdUserScoreService.updateMdUserScore(mdUserScore));
    }

    /**
     * 删除医生给app用户打的评分
     */
    @PreAuthorize("@ss.hasPermi('appuser:score:remove')")
    @Log(title = "医生给app用户打的评分", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(mdUserScoreService.deleteMdUserScoreByIds(ids));
    }
}
